let nums = [5, 7, 7, 8, 8, 10], target = 8
// let nums = [2, 2], target = 2

var searchRange = function (nums, target) {
    if (!nums.length) {
        return [-1, -1]
    }
    let arr = []
    let len = nums.length
    arr.push(nums.indexOf(target))
    if (arr[0] === -1) {
        return [-1, -1]
    } else {
        arr.push(len - 1 - nums.reverse().indexOf(target))
    }

    return arr
};

console.log(searchRange(nums, target));
